82 #define SLAVE_ADDRESS 0x48
89 WDT_A_hold(WDT_A_BASE);
92 UCS_setExternalClockSource(32768, 0);
96 GPIO_setAsPeripheralModuleFunctionInputPin(
101 EUSCI_B_I2C_initMasterParam
param = {0};
102 param.selectClockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK;
103 param.i2cClk = UCS_getSMCLK();
104 param.dataRate = EUSCI_B_I2C_SET_DATA_RATE_400KBPS;
105 param.byteCounterThreshold = 0;
106 param.autoSTOPGeneration = EUSCI_B_I2C_NO_AUTO_STOP;
107 EUSCI_B_I2C_initMaster(EUSCI_B0_BASE, &
param);
110 EUSCI_B_I2C_setSlaveAddress(EUSCI_B0_BASE,
115 EUSCI_B_I2C_setMode(EUSCI_B0_BASE,
116 EUSCI_B_I2C_TRANSMIT_MODE
120 EUSCI_B_I2C_enable(EUSCI_B0_BASE);
122 EUSCI_B_I2C_clearInterrupt(EUSCI_B0_BASE,
123 EUSCI_B_I2C_TRANSMIT_INTERRUPT0 +
124 EUSCI_B_I2C_NAK_INTERRUPT
128 EUSCI_B_I2C_enableInterrupt(EUSCI_B0_BASE,
129 EUSCI_B_I2C_TRANSMIT_INTERRUPT0 +
130 EUSCI_B_I2C_NAK_INTERRUPT
138 while (EUSCI_B_I2C_SENDING_STOP == EUSCI_B_I2C_masterIsStopSent
141 EUSCI_B_I2C_masterSendMultiByteStart(EUSCI_B0_BASE,
144 __bis_SR_register(CPUOFF + GIE);
156 #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
157 #pragma vector=USCI_B0_VECTOR
159 #elif defined(__GNUC__)
160 __attribute__((interrupt(USCI_B0_VECTOR)))
164 switch(__even_in_range(UCB0IV, USCI_I2C_UCBIT9IFG))
168 case USCI_I2C_UCALIFG:
170 case USCI_I2C_UCNACKIFG:
172 EUSCI_B_I2C_masterSendStart(EUSCI_B0_BASE);
174 case USCI_I2C_UCTXIFG0:
178 EUSCI_B_I2C_masterSendMultiByteNext(EUSCI_B0_BASE,
TXData++);
184 EUSCI_B_I2C_masterSendMultiByteStop(EUSCI_B0_BASE);
MPU_initThreeSegmentsParam param
__bic_SR_register_on_exit(LPM3_bits|GIE)